package com.yanqu.road.server.manager.union.listener;

import com.yanqu.road.entity.enums.eUnionSyncType;
import com.yanqu.road.entity.union.cross.CrossUnionInfo;
import com.yanqu.road.entity.union.cross.CrossUnionMember;
import com.yanqu.road.server.manager.union.trade.CrossUnionTradeMgr;
import com.yanqu.road.server.manger.ICrossUnionSyncListener;

import java.util.List;

public class CrossUnionTradeListener implements ICrossUnionSyncListener {


    @Override
    public void notifySync(int syncType, long playerId, CrossUnionInfo unionInfo, List<CrossUnionMember> memberList) {

        if(syncType == eUnionSyncType.QuitUnion.getValue()){

            CrossUnionTradeMgr.notifyUserQuitUnion(playerId, unionInfo.getUnionUid());

        }else if(syncType == eUnionSyncType.DeleteUnion.getValue()){

            CrossUnionTradeMgr.notifyUnionDelete(unionInfo.getUnionUid());

        }else if(syncType == eUnionSyncType.BeKick.getValue()){

            for (CrossUnionMember member : memberList) {
                CrossUnionTradeMgr.notifyUserQuitUnion(member.getUserId(), unionInfo.getUnionUid());
            }

        }

    }
}
